
export default class Detector {
    constructor(swapped) {
        this.swapped = swapped;
    }
    setNormal(result,nX,nY,nZ) {
        let v = result.normal.elements;
        v[0] = nX;v[1] = nY;v[2] = nZ;
        if(this.swapped) {
            v[0] = -v[0];v[1] = -v[1];v[2] = -v[2];
        }
    }
    addPoint(result,pos1X,pos1Y,pos1Z,pos2X,pos2Y,pos2Z,depth,id) {
        let p = result.points[result.numPoints++];
        p.depth = depth;
        p.id = id;
        let v=null;
        if(this.swapped) {
            v = p.position1.elements;
            v[0] = pos2X;v[1] = pos2Y;v[2] = pos2Z;
            v = p.position2.elements;
            v[0] = pos1X;v[1] = pos1Y;v[2] = pos1Z;
        } else {
            v = p.position1.elements;
            v[0] = pos1X;v[1] = pos1Y;v[2] = pos1Z;
            v = p.position2.elements;
            v[0] = pos2X;v[1] = pos2Y;v[2] = pos2Z;
        }
    }
    detectImpl(result,geom1,geom2,tf1,tf2,cachedData) {
    }
    detect(result,geom1,geom2,transform1,transform2,cachedData) {
        result.numPoints = 0;
        let _g = 0,v=null, _g1 = result.points;
        while(_g < _g1.length) {
            let p = _g1[_g];
            ++_g;
            v=p.position1.elements;
            v[0]=v[1]=v[2]=0;
            v=p.position2.elements;
            v[0]=v[1]=v[2]=0;
            p.depth = 0;
            p.id = 0;
        }
        v=result.normal.elements;
        v[0]=v[1]=v[2]=0;
        if(this.swapped) {
            this.detectImpl(result,geom2,geom1,transform2,transform1,cachedData);
        } else {
            this.detectImpl(result,geom1,geom2,transform1,transform2,cachedData);
        }
    }
}